
print('Введите скобочную последовательность')
f = input()
set1 = []
j = 0
for e in f:
    if e == '(' or e == '[' or e == '{' or e == '<':
        set1.append(e)
    elif e == ')':
        if len(set1) != 0:
            if set1.pop(-1) != '(':
                j = 1
                print('False')
                break
            else:
                continue
        else:
            j = 1
            print("False")
            break
    elif e == ']':
        if len(set1) != 0:
            if set1.pop(-1) != '[':
                j = 1
                print('False')
                break
            else:
                continue
        else:
            j = 1
            print("False")
            break
    elif e == '}':
        if len(set1) != 0:
            if set1.pop(-1) != '{':
                j = 1
                print('False')
                break
            else:
                continue
        else:
            j = 1
            print("False")
            break
    elif e == '>':
        if len(set1) != 0:
            if set1.pop(-1) != '<':
                j = 1
                print('False')
                break
            else:
                continue
        else:
            j = 1
            print("False")
            break
if len(set1) != 0:
    if j != 1:
        print("False")
        j = 1
if j == 0:
    print("True")